Handlers for Stay-Open Script Applications
By default, a script application that receives a Run or Open command handles that single command and then quits. This allows it to perform a single task and get out of your way. In contrast, a stay-open script application (one saved with the Stay Open checkbox selected in the Script Editor's Save As dialog box) stays open after it's launched.A stay-open script application can be used for any of these purposes:
All stay-open applications receive periodic Idle events. If a stay-open script application includes a handler for the Idle event, it can perform periodic actions whenever it is not responding to other events. If a stay-open script application includes a handler for the Quit event, it can perform some action, such as checking with the user, before quitting.
- If you run a script frequently, it runs faster as a stay-open application than it does if it has to be launched each time.
- Stay-open script applications can receive and handle other commands in addition to Run and Open. This allows you to use a script application as a script server that, when its running, provides a collection of handlers that can be invoked by any other script.
- Stay-open script applications can perform periodic actions, even in the background, as long as the script application is running.
Subtopics
- Idle Handlers
- Quit Handlers
- Interrupting a Script Application's Handlers